﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="房产销冠, 房地产,卡考网络"/>
    <meta name="description" content="上海卡考网络有限公司"/>
    <title>房产销冠</title>
    <base href="http://static.tops001.com/pointstore/" />
    <link rel="stylesheet" href="css/global.css" type="text/css"/>
    <link rel="stylesheet" href="css/form.css" type="text/css"/>
    <link href="../../bootstrap/iCheck-master/skins/minimal/orange.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css" type="text/css"/>
    <link href="css/bootstrap-switch.css" rel="stylesheet" type="text/css"/>
    <script src="../jq+bs+art.js" type="text/javascript"></script>
    <script src="js/jquery-form.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../bootstrap/iCheck-master/icheck.js"></script>
    <script type="text/javascript" src="js/bootstrap-switch.min.js"></script>
    <script type="text/javascript" src="js/WdatePicker.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/formValidator.js"></script>
    <script type="text/javascript" src="../kk.js"></script>
    <!--<link href="Scripts/webuploader/webuploader.css" rel="stylesheet"/>
    <script src="Scripts/webuploader/webuploader.min.js" type="text/javascript"></script>
    <script src="Scripts/webuploader/webupload.expand.js" type="text/javascript"></script>-->
    <!--<script charset="utf-8" src="js/kindeditor-min.js"></script>-->
    <!--<script charset="utf-8" src="js/zh_CN.js"></script>-->
    <script type="text/javascript">
        $(document).ready(function() {
            initInput();
        });

        function initInput() {
            $('.lab112 :checkbox').iCheck({
                checkboxClass: 'icheckbox_minimal-orange',
                radioClass: 'iradio_minimal-orange',
                increaseArea: '20%' // optional
            });
            $('.lab112 :radio').iCheck({
                checkboxClass: 'icheckbox_minimal-orange',
                radioClass: 'iradio_minimal-orange',
                increaseArea: '20%' // optional
            });
        }
    </script>
    <script type="text/javascript">
        $(function() {
            //单图上传
            $("#btnUpLoadL").powerWebUpload({
                onComplete: function(data) {
                    //alert(JSON.stringify(data));
                    $('#imgBuilding').attr('src', "http://" + window.location.host + data.filePath);
                    $("#picUrl").val(data.filePath);
                },
                PostbackHold: false
            });
            //多图上传
            var imgUrl = $("#productPic").val();
            $("#btnUpLoadList").powerWebUpload({
                onComplete: function(data) {
                    var str = "<div class='frompic2 fl'><div><img src='http://" + window.location.host + data.filePath + "'  width='105' height='77' /></div><div class='picdetline2'><img src='images/from_picclose.png' />删除</div>";
                    $("#imgList").append(str);

                    if (imgUrl != "" || imgUrl != null) {
                        //alert(imgUrl);
                        imgUrl += "|";
                    }
                    imgUrl += data.filePath;
                    $("#productPic").val(imgUrl);

                },
                PostbackHold: true,
                ShowDownload: true
            });

        });

    </script>
</head>
<body style="background: #f1f1f1;">
    <div class="main01 pb50">
        <div class="fromtit1 clearfix">
            <h1 class="ff">商品管理》编辑商品</h1>
            <a href="#" class="gouback">返回</a>
        </div>
        <div class="fromtit2 clearfix">
            <h2 class="ff">基本信息</h2>
        </div>
        <div class="frommod clearfix">
            <form id="form1" action="">
                <input type="hidden" name="Kid" id="Kid" value="" />
                <table border="0" cellspacing="0" cellpadding="0" class="fromtab1">
                    <tr>
                        <th>有效期：&nbsp;</th>
                        <td>
                            <label class="lab112"><span id="beginTime">2015-01-16</span>至<span id="endTime">2015-06-08</span></label>
                        </td>
                    </tr>
                    <tr>
                        <th>商品名称：&nbsp;</th>
                        <td>
                            <input type="text" id="productName" name="productName" value="" class="inpall inp435" placeholder="请填写商品标题" maxlength="16" validatetype="*notempty" />
                        </td>
                    </tr>
                    <tr>
                        <th>详细说明：&nbsp;</th>
                        <td>
                            <textarea id="description" name="description" rows="" cols="" class="textall02 text435" placeholder="请输入详细说明" validatetype="notempty"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>缩略图：&nbsp;</th>
                        <td>
                            <div class="clearfix">
                                <div class="frompic1 fl" id="">
                                    <div>
                                        <img id="imgBuilding" width="105" height="77" />
                                    </div>
                                    <div class="picdetline">
                                        <img src="images/from_picclose.png" alt=""/>
                                        删除
                                    </div>
                                </div>
                                <div class="fl">
                                    <div class="picinfos" id="btnUpLoadL">(请上传200px*150px的图片 )</div>
                                    <input type="hidden" id="picUrl" name="picUrl" value="" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <!--<tr>
                        <th>详情图：&nbsp;</th>
                        <td>
                            <div class="clearfix">
                                <div class="frompic1 fl">
                                    <div>
                                        <img src="images/build_pics.jpg" alt=""/>
                                    </div>
                                    <div class="picdetline">
                                        <img src="images/from_picclose.png" />
                                        删除
                                    </div>
                                </div>
                                <div class="fl">
                                    <div class="picinfos" id="btnUpLoadList">(请上传200px*150px的图片 )</div>
                                    <input type="hidden" id="productPic" name="productPic" value="" />
                                    <a href="#" class="picbtn">选择图片</a>
                                </div>
                            </div>
                        </td>
                    </tr>-->
                    <tr>
                        <th>需要积分：&nbsp;</th>
                        <td>
                            <input type="text" id="pointNum" name="pointNum" value="" class="inpall inp435" placeholder="请输入消耗积分" validatetype="*number" />
                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <label class="lab112">
                                <input type="radio" name="isSelect"  value="0" />&nbsp;&nbsp;自动处理</label>
                            <label class="lab112">
                                <input type="radio" name="isSelect" value="1" />&nbsp;&nbsp;手动处理</label>
                            <input type="hidden" id="status" name="status" value="0" />
                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <div class="sinput">
                                <input type="button" class="Save" value="保存" onclick="f_SubmitSave()" />
                                <input type="button" class="Cancel" value="取消" onclick="f_Back()"/>
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            f_GetProduct();
        });
        //kk.api.add("a", "http://192.168.1.85:1060");
        var apiUrl = "http://"+window.location.host+"/";
        //获取商品信息
        function f_GetProduct(){
            $.getJSON(apiUrl+"/PointProduct/Get",{
                Kid: GetUrlParam("kid")

            },function (res) {
                //alert(JSON.stringify(res));
                if (res.Code != 0 && res.Data.length > 0) {
                    return;
                }
                $("#imgBuilding").attr("src", res.Data.F_PicUrl);
                $("#picUrl").val(res.Data.F_PicUrl);
                $("#Kid").val(res.Data.Kid);
                $("#productName").val(res.Data.F_ProductName);
                $("#pointNum").val(res.Data.T_ExchangeRule.F_PointNum);
                $("#description").val(res.Data.F_Description);
                $("#beginTime").text(res.Data.T_ExchangeRule.F_BeginTime);
                $("#endTime").text(res.Data.T_ExchangeRule.F_EndTime);
                $("input[name='isSelect'][value=" + res.Data.T_ExchangeRule.F_Status + "]").attr("checked", true);
                $("input[name='isSelect'][value=" + res.Data.T_ExchangeRule.F_Status + "]").parent().addClass("checked");
            });
        }

        //提交保存及验证
        $(".inpall").blur(function () {
            validate($(this));
        })
        $(document).ready(function () {
            validateInit("");
        });

        //保存
        function f_SubmitSave() {   
            //表单验证
            if (!validate("#form1 input[validateType]")) {
                return;
            }
            //if (!$("#form1").form("validate")) {

            //    return false;
            //}
           // alert(JSON.stringify($("#form1:input[value],textarea").serializeArray()));
            if ($("input[name='isSelect']").eq(0).prop("checked")) {
                $("#status").val("0");
            } else {
                $("status").val("1");
            }
            $.post(apiUrl+"/PointProduct/UpdateField", $("#form1 :input[value],textarea").serializeArray(), function (res) {
                var obj = eval('(' + res + ')');
                 //alert(JSON.stringify(obj));
                if (obj.Code != "0" && obj.Data != "1") {
                    return $kk.alert(res.Message, "提示");
                }
                
                $kk.popup("保存成功", "success", 1500);
                
                setTimeout(function () { f_Back();}, 1000);
            });
        }
        function f_Back() {
            self.location = document.referrer;
        }
    </script>

    <script type="text/javascript">
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?645933809c922fa8687b58befbd7f4e7";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
    </script></body>
</html>
